<% title "#{admin_title} #{t('team_insights', site_name: AppSettings['settings.site_name'])}" %>

<div class="team-members row">
  <div class="col-md-2">
    <%= render partial: 'admin/reports/reports_nav' %>
  </div>
  <div class="col-md-10 main-panel">

    <%= render partial: 'admin/reports/report_header', locals:
        {
          report_name: t('team_insights', site_name: AppSettings['settings.site_name']),
          report_path: "admin_team_reports_path"
        } %>

    <div class="insights-blurb">
      <h2 style="margin-top: 0;">
      <small>
        <% if @topic_count > 0 %>
          <%= t('insights_blurb_one', count: @topic_count, period: h(@interval.sentence_case)).html_safe %>
          <%= t('insights_blurb_two', number_replied: @responded_topics.count, percentage_replied: number_to_percentage(@responded_topics.count.to_f / @topic_count.to_f * 100.00, precision: 1)).html_safe %>
          <%= t('insights_blurb_three_html', response_time: distance_of_time_in_words(@median_first_response_time)) if @responded_topics.count > 0 %>
        <% else %>
          <%= t('no_discussions', period: h(@interval)).html_safe %>
        <% end %>
      </small>
      </h2>
    </div>
    <div class"row">

      <% @agents = Topic.undeleted.select(:assigned_user_id).where('assigned_user_id IS NOT NULL').distinct %>
      <% @agents.each do |t| %>

      <%
        # figure out ideal column width
        # this could (and maybe should) be done with javascript
        @cols = case @agents.count
        when 1
          5
        when 2
          4
        when 3
          3
        when 4
          2
        else
          2
        end
      %>
      <%= render partial: 'agent_stats', object: t %>
      <% end %>
    </div>
  </div>
</div>

</div>
